package com.cyq.day14.classWork1;

import java.util.Scanner;

public class MyMath {
    Scanner scanner=new Scanner(System.in);
    Rectangle rec=new Rectangle();
    public int judge(){
        System.out.println("请输入你要计算的四边形是哪种四边形：1.平行四边形 2.梯形");
        return scanner.nextInt();
    }
    public double areaMath(){
        double result;
        int a=judge();
        System.out.println("请依次输入高长，底长，宽，高");
        rec.topLength= scanner.nextInt();
        rec.bottonLength=scanner.nextInt();
        rec.width=scanner.nextInt();
        rec.high=scanner.nextInt();
        if (a==1){
            result=rec.topLength*rec.high;
        }else{
            result=(rec.topLength+rec.bottonLength)*rec.high/2;
        }
        return result;
    }
    public double perimeterMath(){
        double result;
        result=rec.topLength+rec.bottonLength+rec.width*2;
        return result;

    }
}
